
Linux Fundamentals
vi
18.4. output redirection and pipes ............................................................................................ 176
18.5. joining stdout and stderr ................................................................................................. 176
18.6. input redirection ............................................................................................................... 177
18.7. confusing redirection ....................................................................................................... 178
18.8. quick file clear ................................................................................................................. 178
18.9. practice: input/output redirection .................................................................................... 179
18.10. solution: input/output redirection .................................................................................. 180
19. filters ............................................................................................................................................ 181
19.1. cat ..................................................................................................................................... 182
19.2. tee ..................................................................................................................................... 182
19.3. grep .................................................................................................................................. 182
19.4. cut .................................................................................................................................... 184
19.5. tr ....................................................................................................................................... 184
19.6. wc ..................................................................................................................................... 185
19.7. sort ................................................................................................................................... 186
19.8. uniq .................................................................................................................................. 187
19.9. comm ............................................................................................................................... 188
19.10. od ................................................................................................................................... 189
19.11. sed .................................................................................................................................. 190
19.12. pipe examples ................................................................................................................ 191
19.13. practice: filters ............................................................................................................... 192
19.14. solution: filters ............................................................................................................... 193
20. basic Unix tools .......................................................................................................................... 195
20.1. find ................................................................................................................................... 196
20.2. locate ................................................................................................................................ 197
20.3. date ................................................................................................................................... 197
20.4. cal ..................................................................................................................................... 198
20.5. sleep ................................................................................................................................. 198
20.6. time .................................................................................................................................. 199
20.7. gzip - gunzip .................................................................................................................... 200
20.8. zcat - zmore ..................................................................................................................... 200
20.9. bzip2 - bunzip2 ................................................................................................................ 201
20.10. bzcat - bzmore ............................................................................................................... 201
20.11. practice: basic Unix tools .............................................................................................. 202
20.12. solution: basic Unix tools .............................................................................................. 203
21. regular expressions .................................................................................................................... 205
21.1. regex versions .................................................................................................................. 206
21.2. grep .................................................................................................................................. 207
21.3. rename .............................................................................................................................. 212
21.4. sed .................................................................................................................................... 215
21.5. bash history ...................................................................................................................... 219
VI. vi ............................................................................................................................................................ 220
22. Introduction to vi ....................................................................................................................... 222
22.1. command mode and insert mode .................................................................................... 223
22.2. start typing (a A i I o O) ................................................................................................ 223
22.3. replace and delete a character (r x X) ............................................................................. 224
22.4. undo and repeat (u .) ....................................................................................................... 224
22.5. cut, copy and paste a line (dd yy p P) ............................................................................ 224
22.6. cut, copy and paste lines (3dd 2yy) ................................................................................ 225
22.7. start and end of a line (0 or ^ and $) .............................................................................. 225
22.8. join two lines (J) and more ............................................................................................. 225
22.9. words (w b) ..................................................................................................................... 226
22.10. save (or not) and exit (:w :q :q! ) .................................................................................. 226
22.11. Searching (/ ?) ................................................................................................................ 226
22.12. replace all ( :1,$ s/foo/bar/g ) ........................................................................................ 227
22.13. reading files (:r :r !cmd) ................................................................................................ 227
22.14. text buffers ..................................................................................................................... 227
22.15. multiple files .................................................................................................................. 227